package com.learning.jquizenglish.common.controller;

import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.learning.jquizenglish.JQuizAppConfig;
import com.learning.jquizenglish.R;
import com.learning.jquizenglish.screen.MainScreen;
import com.learning.jquizenglish.screen.doquiz.DoQuizScreen;
import com.learning.jquizenglish.screen.flashcard.FlashCardCategoryScreen;
import com.learning.jquizenglish.screen.flashcard.FlashCardScreen;
import com.learning.jquizenglish.screen.more.HelpScreen;
import com.learning.jquizenglish.screen.more.HighScoreScreen;
import com.learning.jquizenglish.screen.more.StatisticScreen;
import com.learning.jquizenglish.screen.settings.SettingScreen;

public class HeaderBarFactory {

	protected Fragment mFrag;
	public HeaderBarQuiz mHeaderBarQuiz;
	public HeaderBarFactory(Fragment frag){
		mFrag = frag;
	}
	
	public View onCreateHeaderView(LayoutInflater inflater,
			ViewGroup container) {
		if(mFrag instanceof SettingScreen
				|| mFrag instanceof HelpScreen
				|| mFrag instanceof FlashCardCategoryScreen
				|| mFrag instanceof FlashCardScreen
				|| mFrag instanceof HighScoreScreen
				|| mFrag instanceof StatisticScreen
				|| mFrag instanceof DoQuizScreen){
			mHeaderBarQuiz = new HeaderBarQuiz(mFrag);
			return mHeaderBarQuiz.onCreateHeaderView(inflater, container);
		}else if (mFrag instanceof MainScreen){
			View v = inflater.inflate(R.layout.header_bar, container,false);
			if (JQuizAppConfig.IS_LISTENING_APP) {
				((TextView) v.findViewById(R.id.txtTitle)).setText("English Listening Test");
			}else{
				((TextView) v.findViewById(R.id.txtTitle)).setText("English Grammar Test");
			}
			return v;
		}else{
			return null;
		}
	}
	
}
